# Contributor: H <agathos5@gmail.com>
# Maintainer:
pkgname=megatools
pkgver=1.10.2
pkgrel=0
pkgdesc="Megatools is a collection of programs for accessing Mega.nz service from a command line of your desktop or server."
url="https://megatools.megous.com"
arch="all"
license="GPL-2.0"
makedepends="curl-dev glib-dev openssl-dev gmp-dev asciidoc"
subpackages="$pkgname-doc"
source="https://megatools.megous.com/builds/megatools-$pkgver.tar.gz"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	./configure --prefix=/usr
	make
}

check() {
	cd "$builddir"
	make check
	for i in  megacopy megadf megadl megaget megals megamkdir megaput megareg megarm; do
		msg $i
		./$i --version
	done
}

package() {
	cd "$builddir"
	#make DESTDIR="$pkgdir" install
	./install-sh -c -d "${pkgdir}/usr/bin"
	./install-sh -c -d "${pkgdir}/usr/share/doc/megatools"
	./install-sh -c -d "${pkgdir}/usr/share/man/man1"
	./install-sh -c -d "${pkgdir}/usr/share/man/man5"
	./install-sh -c -d "${pkgdir}/usr/share/man/man7"
	./install-sh -c -m 755 megacopy megadf megadl megaget megals megamkdir megaput megareg megarm "${pkgdir}/usr/bin"
	./install-sh -c -m 644 LICENSE NEWS TODO README INSTALL HACKING "${pkgdir}/usr/share/doc/megatools"
	./install-sh -c -m 644 docs/megadf.1 docs/megaget.1 docs/megals.1 docs/megamkdir.1 docs/megaput.1 docs/megareg.1 docs/megarm.1 \
													docs/megacopy.1 docs/megadl.1 "${pkgdir}/usr/share/man/man1"
	./install-sh -c -m 644 docs/megarc.5 "${pkgdir}/usr/share/man/man5"
	./install-sh -c -m 644 docs/megatools.7 "${pkgdir}/usr/share/man/man7"
}

sha512sums="6d9a5dcba6be12bce38313c3481565b2f8671e354d2e021614b62c2cf30963b9e4a87574dd80b36613290db7721e3ef4d32072a19efee76ff292b17bc6c2bafe  megatools-1.10.2.tar.gz"
